package com.todo.common.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author azhebuxing
 * @date 2024/4/23 10:25
 * @description
 */
@Getter
@AllArgsConstructor
public enum AllowedCommentEnum {

    ALLOWED(0, "ALLOWED", "允许"),
    NOT_ALLOWED(1, "NOT_ALLOWED", "不允许"),
    FRIENDS_ALLOWED(2, "FRIENDS_ALLOWED", "朋友圈允许"),
    FRIENDS_NOT_ALLOWED(3, "FRIENDS_NOT_ALLOWED", "朋友圈不允许"),
    ;

    private static Map<Integer, AllowedCommentEnum> typeMap = Arrays
            .stream(AllowedCommentEnum.values())
            .collect(Collectors.toMap(AllowedCommentEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static AllowedCommentEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
